home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_2 / rndwel10.zip / RANDWEL.PAS < prev   
Pascal/Delphi Source File  |  1992-03-26  |  1KB  |  66 lines

  1.  
  2. (*
  3.  * randwel - select random welcome screens for PCBoard and most other
  4.  *           BBS programs.
  5.  *
  6.  * Copyright 1992 Samuel H. Smith.
  7.  *
  8.  *)
  9.  
  10. {$M 8000,8000,8000}
  11.  
  12. uses dos;
  13.  
  14. const
  15.    config_file = 'RANDWEL.CFG';
  16.    version = 'v1.0 of 3/27/92';
  17.    max_rand = 200;
  18.  
  19. var
  20.    fd:         text;
  21.    destfile:   string;
  22.    srcfile:    array[1..max_rand] of string[65];
  23.    count:      integer;
  24.    r:          integer;
  25.    command:    string;
  26.  
  27. procedure usage(msg: string);
  28. begin
  29.    writeln;
  30.    writeln('RANDWEL - Random welcome selection utility  ',version);
  31.    writeln('Copyright 1992 Samuel H. Smith');
  32.    writeln;
  33.    writeln('Error:   ',msg);
  34.    writeln;
  35.    writeln('Usage:   randwel CONFIG_FILE');
  36.    writeln('Example: randwel randwel.cfg');
  37.    halt;
  38. end;
  39.  
  40. begin
  41.    randomize;
  42.    if paramcount <> 1 then
  43.       usage('No configuration file specified');
  44.  
  45.    assign(fd,paramstr(1));
  46.    {$i-} reset(fd); {$i+}
  47.    if ioresult <> 0 then
  48.       usage('Can''t open configuration file: '+paramstr(1));
  49.  
  50.    readln(fd,destfile);
  51.    count := 0;
  52.    while not eof(fd) do
  53.    begin
  54.       if count < max_rand then
  55.          inc(count);
  56.       readln(fd,srcfile[count]);
  57.    end;
  58.    close(fd);
  59.  
  60.    r := random(count)+1;
  61.    command := 'copy '+srcfile[r]+' '+destfile+' >nul';
  62.    writeln(command);
  63.    exec(getenv('COMSPEC'),'/c '+command);
  64. end.
  65.  
  66.